var c  =require('../lib/common.js');
var cf = require('../lib/config.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls: [
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/phpbanner.png',
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/phpbanner.png',
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/phpbanner.png',
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/phpbanner.png',
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/phpbanner.png',
    ],
    imgUrls1: [
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/php639975604581556023.png',
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/php639975604581556023.png',
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/php639975604581556023.png',
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/php639975604581556023.png',
      'http://wyk-img-1255995999.cos.ap-beijing.myqcloud.com/user/php639975604581556023.png',
    ],
    toph:false
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
        c.verlogin(this);
        c.ajax(
          cf.hostapi +'getMenusInfo',
         {},
         res=>{
           console.log(res.data.data);
           this.setData({ data: res.data.data});
         }
        )
    c.ajax(
      cf.hostapi + 'getAdvertInfo',
      {},
      res => {
        var lower=res.data.data.lower;
        var middle= res.data.data.middle;
        var top =res.data.data.top;
        that.setData({ top: top, middle: middle, lower: lower})
      }
    )
  },
  userinfo:function(e){
    c.clicklogin(e,this);
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
   topclickdelete:function(){
    this.setData({ toph:true})
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  onemenuid:function(e){
    var type = e.currentTarget.dataset.type;
    var id   = e.currentTarget.dataset.id;
    console.log(type);
    if(type=='bwq'){
      var url = '/pages/bangwoqu/bangwoqu?id=' + id;
    } else if(type=='bws'){
      var url = '/pages/bangwosong/bangwosong?id=' + id;
    }else if(type=='bwm'){
      var url = '/pages/bangwomai/bangwomai?id=' + id;
    } else if (type == 'bwz'){
      var url = '/pages/bangwozuo/bangwozuo?id=' + id;
    } else if (type == 'dj' || type == 'qkd' || type == 'sxh' || type == 'myp'){
      var url = '/pages/daijia/daijia?id=' + id;
    } else if (type == 'mxy'){
      var url = '/pages/maixiangyan/maixiangyan?id=' + id;
    } else if (type == 'bpd'){
      var url = '/pages/bangpaidui/bangpaidui?id=' + id;
    } 
    wx.navigateTo({
      url: url,
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  }
})